home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / vidbasic.zip / VMOVE.ASM < prev    next >
Assembly Source File  |  1990-11-29  |  6KB  |  190 lines

  1. ;«RM82»«TS8,16,24,32,40,48»
  2. ; Updated 11/20/90
  3.  
  4. ;============================================================================
  5. ;   Copyright (C) Copr. 1990 by Sidney J. Kelly
  6. ;           All Rights Reserved.
  7. ;           Sidney J. Kelly
  8. ;           150 Woodhaven Drive
  9. ;           Pittsburgh, PA 15228
  10. ;           home phone 412-561-0950 (7pm to 9:30pm EST)
  11. ;============================================================================
  12.  
  13. ;===========================================================================
  14. ;DECLARE FUNCTION S2BUFF  ;put text screen in buffer
  15. ;DECLARE FUNCTION BUFF2S  ;get text screen from buffer
  16. ;
  17. ; Allows movement of text screens, page 0 to and from a buffer.
  18. ; Modified to handle a CGA display so will NOT cause SNOW on a CGA
  19. ;
  20. ; Handles  80 x 25, 80 x 43, and 80 x 50 displays.  Checks current status
  21. ; each time it makes a shift.
  22. ;
  23. ; Storage in Code Segment used to save space in DGROUP, makes DATA near
  24. ; without using up the limited amount of DGROUP space.  However prevents
  25. ; use of program in OS/2 which prohibits any change to CodeSeg values.
  26. ;===========================================================================
  27.  
  28. DOSSEG
  29. .MODEL MEDIUM
  30.  
  31.         PUBLIC   S2BUFF, BUFF2S
  32.  
  33. .data
  34.     ;external data so all video routines can access
  35.     EVEN
  36.     EXTRN  B$DVIDEOSEG:WORD
  37.     EXTRN  B$DVIDEOPORT:WORD
  38.     EXTRN  B$DVIDEOINSTL:BYTE
  39. .code
  40.  EXTRN   Get_Adapter:FAR
  41.  INCLUDE  NOWAIT.INC      ;all the video common macros
  42. ;------------------------------Data Area----------------------------------
  43.     EVEN            ;speed up access on an 80286,8086 machine
  44.     BUFF            DW      4000 DUP(?) ;allow 80 x 25 to 80 x 50 display
  45.  
  46. EVEN
  47. S2BUFF   PROC    FAR
  48.     Push            BP             ;Save current display in the buffer
  49.     Push            DS
  50.     Push            SI
  51.     Push            DI
  52.  
  53.         Assume          DS:@data
  54.  
  55.     Cmp             B$DVIDEOINSTL,1
  56.     JE              Skip_Ahead
  57.     Call         Get_Adapter      ;get display information
  58.  
  59. Skip_Ahead:
  60.                          ;determine video page size
  61.                          ;do it the hard way because of error
  62.                          ;in certain HERC clones
  63.     Xor           AX,AX            ;clear AX
  64.     Mov           ES,AX            ;set ES to BIOS ram
  65.     Xor           BH,BH            ;clear high byte
  66.     Mov           BL,Byte Ptr ES:[0484h]  ;read ROW from BIOS ram
  67.     Or            BL,BL   ;is ROW 0? (i.e. is this CGA, HERC or MONO?)
  68.     JNZ           @f               ;nope, it is a EGA, MCGA or VGA
  69.     Mov           BL,24            ;set default ROW to 24
  70. @@:
  71.     Inc           BL               ;remove 0 bias of ROW
  72.     Mov           AX,ES:[044Ah]    ;read COLUMN from BIOS ram
  73.     Mul           BX               ;multiply ROW times COLUMN
  74.     Mov        CX,AX         ;load counter
  75.  
  76.     Mov        DX,B$DVIDEOPORT  ;DX =  VIDEOPORT address or 0
  77.         Mov             AX,CS            ;point ES to CS
  78.     Mov             ES,AX
  79.  
  80.     ;have to be finished with stack or .data before can change DS
  81.         Mov             DS,B$DVIDEOSEG ;DS points to video buffer
  82.  
  83.     ;MUST KEEP THESE TO USE OFFSET RELATIVE TO THE CODE SEGMENT
  84.     Assume        DS:NOTHING, ES:NOTHING
  85.  
  86.         Mov             DI,OFFSET CS:BUFF
  87.     Xor             SI,SI          ;offset of display page 0
  88.         Cld                            ;all data moves below will be forward
  89.         Or              DL,DL          ;monochrome or EGA (is DL=0)?
  90.     JZ              Mono           ;yes, skip over the retrace stuff
  91.  
  92. EVEN
  93. CGA_Loop:
  94.         CLI                            ;prevent interrupts
  95.     Wait_CGA_Retrace               ;run CGA retrace macro
  96.     Movsw                          ;move the data in one operation
  97.     STI                            ;allow interrupts again
  98.     Loop            CGA_Loop       ;loop until done
  99.  
  100.     Jmp             Short Exit     ;skip over the mono routine and exit
  101.  
  102. Mono:
  103.     Rep             Movsw          ;move the data in one operation
  104.                        ;Move DS:SI to ES:DI
  105. Exit:
  106.     Pop             DI             ;restore stack
  107.     Pop             SI
  108.     Pop             DS
  109.  
  110.         Assume          DS:@data
  111.  
  112.     Pop             BP
  113.     Ret
  114. S2BUFF   ENDP
  115.  
  116. ;===========================================================================
  117. ; Restores saved buffer to screen
  118. ;===========================================================================
  119.  
  120. EVEN
  121. BUFF2S   PROC    FAR
  122.     Push            BP                ;Save registers
  123.     Push            DS
  124.     Push            SI
  125.     Push            DI
  126.  
  127.         Assume          DS:@data
  128.  
  129.     Cmp             B$DVIDEOINSTL,1
  130.     JE              skip_over
  131.     Call         Get_Adapter     ;get display information
  132.  
  133. skip_over:
  134.                          ;determine video page size
  135.                          ;do it the hard way because of error
  136.                          ;in certain HERC clones
  137.     Xor           AX,AX            ;clear AX
  138.     Mov           ES,AX            ;set ES to BIOS ram
  139.     Xor           BH,BH            ;clear high byte
  140.     Mov           BL,Byte Ptr ES:[0484h]  ; read ROW from BIOS ram
  141.     Or            BL,BL   ; is ROW 0? (i.e. is this CGA, HERC or MONO?)
  142.     JNZ           @f               ;nope, it is a EGA, MCGA or VGA
  143.     Mov           BL,24            ;set default ROW to 24
  144. @@:
  145.     Inc           BL               ;remove 0 bias of ROW
  146.     Mov           AX,ES:[044Ah]    ;read COLUMN from BIOS ram
  147.     Mul           BX               ;multiply ROW times COLUMN
  148.     Mov        CX,AX         ;load counter
  149.     
  150.     Mov             ES,B$DVIDEOSEG  ;ES points to video buffer
  151.     Mov             DX,B$DVIDEOPORT ;DX contains B$DVIDEOPORT address or 0
  152.  
  153.     Mov             AX,CS           ;set DS to code segment
  154.     Mov             DS,AX
  155.  
  156.         ;MUST KEEP THESE TO USE OFFSET RELATIVE TO THE CODE SEGMENT
  157.     Assume        DS:NOTHING, ES:NOTHING
  158.  
  159.     Mov             SI, OFFSET CS:BUFF
  160.     Xor             DI,DI        ;offset on screen page 0
  161.  
  162.     Cld                          ;all data moves below will be forward
  163.     Or              DL,DL        ;monochrome or EGA (is DL = 0)?
  164.     JZ              Mono1        ;yes, skip over the retrace stuff
  165.  
  166. EVEN
  167. CGA1:
  168.  
  169.     CLI                          ;prevent interrupts
  170.     Wait_CGA_Retrace             ;run CGA retrace macro
  171.     Movsw                        ;move data by words  DS:SI to ES:DI
  172.     STI                          ;allow interrupts again
  173.     Loop            CGA1         ;loop until done
  174.     Jmp             Short Exit1  ;skip over the mono routine and exit
  175.  
  176. Mono1:
  177.     Rep             Movsw        ;move the data in one operation
  178.                      ;Move DS:SI to ES:DI
  179. Exit1:
  180.     Pop             DI           ;restore stack
  181.     Pop             SI
  182.     Pop             DS
  183.  
  184.         Assume          DS:@data
  185.  
  186.     Pop             BP
  187.     Ret
  188. BUFF2S   ENDP
  189. END
  190.